// 模拟空气质量数据
const aqiData = [
    { date: '2024-01-01', city: '北京', aqi: 80, pm25: 40, pm10: 20, ozone: 20 },
    { date: '2024-01-02', city: '北京', aqi: 95, pm25: 50, pm10: 25, ozone: 20 },
    { date: '2024-01-03', city: '北京', aqi: 70, pm25: 30, pm10: 20, ozone: 20 },
    { date: '2024-01-04', city: '北京', aqi: 60, pm25: 25, pm10: 15, ozone: 20 },
    { date: '2024-01-05', city: '北京', aqi: 85, pm25: 45, pm10: 20, ozone: 20 }
];

// 1. 折线图：AQI变化趋势
const lineData = [{
    x: aqiData.map(d => d.date),
    y: aqiData.map(d => d.aqi),
    type: 'scatter',
    mode: 'lines+markers',
    name: '北京AQI'
}];
Plotly.newPlot('lineChart', lineData, { title: 'AQI变化趋势' });

// 2. 饼图：污染物占比（取最新一天数据）
const latest = aqiData[aqiData.length - 1];
const pieData = [{
    labels: ['PM2.5', 'PM10', '臭氧'],
    values: [latest.pm25, latest.pm10, latest.ozone],
    type: 'pie'
}];
Plotly.newPlot('pieChart', pieData, { title: '污染物占比' });

// 3. 3D散点图：AQI、温度、湿度关系（模拟数据）
const scatterData = [{
    x: aqiData.map(d => d.aqi),
    y: [2, 4, 3, 5, 2], // 模拟温度
    z: [60, 65, 58, 70, 62], // 模拟湿度
    mode: 'markers',
    type: 'scatter3d',
    marker: { size: 5 }
}];
Plotly.newPlot('scatter3DChart', scatterData, {
    title: 'AQI-温度-湿度关系',
    scene: { xaxis: { title: 'AQI' }, yaxis: { title: '温度(℃)' }, zaxis: { title: '湿度(%)' } }
});